package com.test.redis_demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.test.redis_demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("")
public class LoginController {

    @Autowired
    private UserService userService;

    @RequestMapping("toLogin")
    public String toLogin(){
        return "login";
    }

    @RequestMapping("login")
    @ResponseBody
    public JSONObject userLogin(HttpServletRequest request,HttpServletResponse response){
        String userName = request.getParameter("userName");
        String passw = request.getParameter("passWord");
        return userService.userLogin(response,userName,passw);
    }

}
